<template>
  <div class="mod-dict">
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <el-form-item>
        <el-input v-model="dataForm.name" placeholder="请假类型" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table
      :data="dataList"
      border
      v-loading="dataListLoading"
      @selection-change="selectionChangeHandle"
      style="width: 100%;"
    >
      <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
      <el-table-column prop="id" header-align="center" align="center" label="任务ID"></el-table-column>
      <el-table-column prop="name" header-align="center" align="center" label="任务名称"></el-table-column>
      <!--<el-table-column-->
      <!--prop="referee"-->
      <!--align="center"-->
      <!--label="提审人">-->
      <!--</el-table-column>-->
      <el-table-column prop="upName" align="center" label="处理人名称"></el-table-column>
      <el-table-column prop="createTime" header-align="center" align="center" label="通知时间"></el-table-column>
      <el-table-column prop="endTime" header-align="center" align="center" label="处理时间"></el-table-column>
      <el-table-column fixed="right" header-align="center" align="center" width="150" label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="infoImageHandle(scope.row.instanceId)">详情</el-button>
          <!--<el-button type="text" size="small" @click="jumpOneTaskHandle(scope.row.id)">撤回上一步</el-button>-->
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper"
    ></el-pagination>
    <!-- 弹窗, 新增 / 修改 -->
    <Detail v-if="detailVisible" ref="detilsOrder"></Detail>
  </div>
</template>

<script>
import Detail from "./done-detail";
export default {
  data() {
    return {
      dataForm: {
        name: ""
      },
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      dataListSelections: [],
      detailVisible: false
    };
  },
  components: {
    Detail
  },
  activated() {
    this.getDataList();
  },
  methods: {
    // 获取数据列表
    getDataList() {
      this.dataListLoading = true;
      this.$http({
        url: this.$http.adornUrl("/activiti/done/list"),
        method: "get",
        params: this.$http.adornParams({
          page: this.pageIndex,
          limit: this.pageSize,
          name: this.dataForm.name
        })
      }).then(({ data }) => {
        if (data && data.code === 0) {
          this.dataList = data.page.list;
          this.totalPage = data.page.totalCount;
        } else {
          this.dataList = [];
          this.totalPage = 0;
        }
        this.dataListLoading = false;
      });
    },
    infoImageHandle(id, instanceId) {
      this.detailVisible = true;
      this.$nextTick(() => {
        this.$refs.detilsOrder.init(id, instanceId);
      });
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
    // 多选
    selectionChangeHandle(val) {
      this.dataListSelections = val;
    }
    // jumpOneTaskHandle(taskId){
    //   this.$http({
    //     url: this.$http.adornUrl(`/activiti/done/jumpOneTask/${taskId}`),
    //     method: 'get',
    //     params: this.$http.adornParams()
    //   }).then(({data}) => {
    //     if (data && data.code === 0) {
    //       this.$message({
    //         message: '操作成功',
    //         type: 'success',
    //         duration: 1500,
    //         onClose: () => {
    //           this.getDataList()
    //         }
    //       })
    //     } else {
    //       this.$message.error(data.msg)
    //       this.getDataList()
    //     }
    //   })
    // },
    // 删除
  }
};
</script>
